package com.jiantong.lawEnforcing.impl.dao;

import com.google.common.collect.Maps;
import com.jiantong.lawEnforcing.model.CasesCheck;
import io.terminus.common.model.Paging;
import io.terminus.common.mysql.dao.MyBatisDao;
import org.springframework.stereotype.Repository;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * 立案审批
 * Created by mz03 on 2017/8/14.
 */
@Repository
public class CasesCheckDao extends MyBatisDao<CasesCheck> {


    public Paging<CasesCheck> pagingList(Integer offset, Integer limit, Map<String, Object> criteria) {
        if(criteria == null) {
            criteria = Maps.newHashMap();
        }

        Long total = getSqlSession().selectOne(sqlId("countList"), criteria);
        if(total <= 0L) {
            return new Paging<>(0L, Collections.emptyList());
        } else {
            criteria.put("offset", offset);
            criteria.put("limit", limit);
            List<CasesCheck> datas = getSqlSession().selectList(sqlId("pagingList"), criteria);
            return new Paging<>(total, datas);
        }
    }
}
